<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class BaseFormRequest extends FormRequest
{
	
	protected $scene = "default";
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return false;
    }
	
	// 场景定义
	public function scenes()
    {
        return [];
    }
	
	// 设置场景
	public function setScene($scene)
    {
        $this->scene = $scene;
    }
	
	//获取规则
	public function getRule()
    {
		$this->setScene($this->route()->getActionMethod());
        return array_get($this->scenes(), $this->scene, []);
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return $this->getRule();
    }
}
